package com.ruoyi.tasks.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.tasks.domain.NucleicAcidTasks;
import com.ruoyi.tasks.service.INucleicAcidTasksService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 核酸任务超时CRUDController
 * 
 * @author ruoyi
 * @date 2022-10-05
 */
@RestController
@RequestMapping("/nucieic")
public class NucleicAcidTasksController extends BaseController
{
    @Autowired
    private INucleicAcidTasksService nucleicAcidTasksService;

    /**
     * 查询核酸任务超时CRUD列表
     */
    @RequiresPermissions("tasks:nucieic:list")
    @GetMapping("/list")
    public TableDataInfo list(NucleicAcidTasks nucleicAcidTasks)
    {
        startPage();
        List<NucleicAcidTasks> list = nucleicAcidTasksService.selectNucleicAcidTasksList(nucleicAcidTasks);
        return getDataTable(list);
    }

    /**
     * 导出核酸任务超时CRUD列表
     */
    @RequiresPermissions("tasks:nucieic:export")
    @Log(title = "核酸任务超时CRUD", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NucleicAcidTasks nucleicAcidTasks)
    {
        List<NucleicAcidTasks> list = nucleicAcidTasksService.selectNucleicAcidTasksList(nucleicAcidTasks);
        ExcelUtil<NucleicAcidTasks> util = new ExcelUtil<NucleicAcidTasks>(NucleicAcidTasks.class);
        util.exportExcel(response, list, "核酸任务超时CRUD数据");
    }

    /**
     * 获取核酸任务超时CRUD详细信息
     */
    @RequiresPermissions("tasks:nucieic:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(nucleicAcidTasksService.selectNucleicAcidTasksById(id));
    }

    /**
     * 新增核酸任务超时CRUD
     */
    @RequiresPermissions("tasks:nucieic:add")
    @Log(title = "核酸任务超时CRUD", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NucleicAcidTasks nucleicAcidTasks)
    {
        return toAjax(nucleicAcidTasksService.insertNucleicAcidTasks(nucleicAcidTasks));
    }

    /**
     * 修改核酸任务超时CRUD
     */
    @RequiresPermissions("tasks:nucieic:edit")
    @Log(title = "核酸任务超时CRUD", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NucleicAcidTasks nucleicAcidTasks)
    {
        return toAjax(nucleicAcidTasksService.updateNucleicAcidTasks(nucleicAcidTasks));
    }

    /**
     * 删除核酸任务超时CRUD
     */
    @RequiresPermissions("tasks:nucieic:remove")
    @Log(title = "核酸任务超时CRUD", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(nucleicAcidTasksService.deleteNucleicAcidTasksByIds(ids));
    }
}
